﻿#pragma once
#include "Common.hpp"


class ThreadCache
{
public:
	// 申请和释放内存对象
	void* Allocate(size_t size);
	void Deallocate(void* ptr, size_t size);
	// 从中⼼缓存获取对象
	void* FetchFromCentralCache(size_t index, size_t size);
	//当_freelists内存过长时，将多余内存返回给中心内存
	void ListTooLong(FreeList& list, size_t size);
private:
	FreeList _freeLists[NFREELIST];
};

// TLS thread local storage
static _declspec(thread) ThreadCache* pTLSThreadCache = nullptr;